package edu.bu.bga.generator;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;

import edu.bu.bga.queue.IntegerQueue;
import edu.bu.bga.queue.Queue;

public class RandomIntegerQueueGenerator implements QueueGenerator {

	private Random random = new Random(System.currentTimeMillis());

	/**
	 * @see edu.bu.bga.generator.QueueGenerator#generateQueue(int)
	 */
	@Override
	public Queue generateQueue(int numPlayers) {
		List<Integer> playerList = new ArrayList<Integer>();

		// first build list of players
		for (int i = 1; i <= numPlayers; i++) {
			playerList.add(i);
		}

		// then randomly shuffle players
		Collections.shuffle(playerList, random);

		// then return queue with new shuffled list
		return new IntegerQueue(playerList);
	}

}
